package com.os.feign;

import com.os.result.Resp;
import feign.Request;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.io.InputStreamSource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.net.URI;


/**
 * @author 风亦未止
 * @date 2023/5/1 23:39
 */
@FeignClient(name = "api-client",url = "empty")
public interface DataService {

    /**
     * 文件上传
     * @param uri
     * @param hash
     * @return
     */
    @PutMapping(value ="/dataServer/{hash}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Resp put(URI uri, @PathVariable("hash") String hash, @RequestPart("file") MultipartFile multipartFile );


    /**
     * 文件获取
     * @param uri 节点url
     * @param hash 文件hash
     * @return
     */
    @GetMapping("/dataServer/{hash}")
    Response get(URI uri, @PathVariable("hash") String hash);

    @PostMapping("/dataServer/temp/{hash}")
    Response post(URI uri,@RequestHeader int size, @PathVariable("hash") String hash);

    @PatchMapping(value = "/dataServer/temp/{uuid}", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE )
    Response patch(URI uri, @PathVariable("uuid") String uuid, @RequestBody byte[] bytes);

    @PutMapping("/dataServer/temp/{uuid}")
    Response put(URI uri, @PathVariable("uuid") String uuid);

    @DeleteMapping("/dataServer/temp/{uuid}")
    Response delete(URI uri, @PathVariable("uuid") String uuid);
}
